package com.basics.channel.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.basics.api.response.channel.CommentListData;
import com.basics.api.response.channel.PostCommentListData;
import com.basics.channel.entity.CyChannelComment;
import com.basics.channel.mapper.CyChannelCommentMapper;
import com.basics.channel.service.CyChannelCommentService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 帖子评论 服务实现类
 * </p>
 *
 * @author WangWei
 * @since 2025-03-09
 */
@Service
public class CyChannelCommentServiceImpl extends ServiceImpl<CyChannelCommentMapper, CyChannelComment> implements CyChannelCommentService {

    @Override
    public List<CommentListData> selectPostCommentList(Long postId){
        return baseMapper.selectPostCommentList(postId);
    }

    @Override
    public int getCommentNumByPostId(Long postId){
        return count(new QueryWrapper<CyChannelComment>().eq("post_id",postId));
    }

    @Override
    public IPage<PostCommentListData> selectCommentList(Page page, Long postId
                                                        , Long userId
                                                        ,Integer commentType,
                                                        String parentId){
        return baseMapper.selectCommentList(page,postId,userId,commentType,parentId);
    }
}
